package cmsoa.helper;


import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import cmsoa.db.pojo.TXtUser;


public class RequestHelper {
	public static String getParameter(String name){
		return ServletActionContext.getRequest().getParameter(name);
	}
	
	public static Map getParameterMap(String name){
		return ServletActionContext.getRequest().getParameterMap();
	}
	
	public static Object getAttribute(String name){
		return ServletActionContext.getRequest().getAttribute(name);
	}
	
	public static void getAttribute(String key, Object obj){
		ServletActionContext.getRequest().setAttribute(key, obj);
	}
	
	public static HttpServletRequest getRequest(){
		return ServletActionContext.getRequest();
	}
	
	public static HttpServletResponse getResponse(){
		return ServletActionContext.getResponse();
	}
	
	public static HttpSession getSession(){
		return ServletActionContext.getRequest().getSession();
	}
	
	public static ServletContext getServletContext(){
		return ServletActionContext.getRequest().getSession().getServletContext();
	}
	
	public static TXtUser getLoginUser(){
		return (TXtUser)RequestHelper.getSession().getAttribute("user");
	}
}
